**************************************************
* TERRORIST KIDNAPPING IN CIVIL WAR
* 
* Blair Welsh (NYU - Abu Dhabi)
* blairwelsh@nyu.edu
*
* International Studies Quarterly, 2023
**************************************************

* Change to respective directory
cd "/Users/bjw9936/Desktop/Welsh23_ISQ"

**************************************************
* MACRO-LEVEL ANALYSIS
**************************************************

* Reported Results (Table A2)
use welsh23_macro.dta, clear

regress lnkidnap infight_b c.lndeathsb kidnap_lag terror_lag soft_lag, cluster(panelid)
regress lnkidnap infight_b lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid)
regress lnkidnap infight_b lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag ln_gdp ln_pop pts_a efindex, cluster(panelid)

* Marginal Effects
regress lnkidnap i.infight_b lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid)
margins infight_b, post
marginsplot, recast(scatter)

regress lnkidnap infight_b lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid)
margins, at(lndeathsb = (0(0.1)12))
marginsplot, recast(line) recastci(rarea)

* Binary Dependent Variable (Table A3)
logistic kidnapb infight_b lndeathsb terror_lag soft_lag, cluster(panelid)
estat ic
logistic kidnapb infight_b lndeathsb foreignspon size nat left rel regimetype territory terror_lag soft_lag, cluster(panelid)
estat ic
logistic kidnapb infight_b lndeathsb foreignspon size nat left rel regimetype territory  terror_lag soft_lag ln_gdp ln_pop pts_a efindex, cluster(panelid)
estat ic

* Negative Binomial Estimation (Table A4) 
nbreg kidnap infight_b c.lndeathsb kidnap_lag terror_lag soft_lag, dispersion(mean) vce(cluster panelid)
nbreg kidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, dispersion(mean) vce(cluster panelid)
nbreg kidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag ln_gdp ln_pop pts_a efindex, dispersion(mean) vce(cluster panelid)

* Dependent Variable as a Proportion (Table A5)
glm propkid infight_b lndeathsb kidnap_lag terror_lag soft_lag, family(binomial) link(logit) cluster(panelid)
glm propkid infight_b lndeathsb size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, family(binomial) link(logit) cluster(panelid)

* Alternative Measures of Variabvles (Table A6)
regress lnkidnap infight lndeathsblag kidnap_lag terror_lag soft_lag, cluster(panelid)
regress lnkidnap infight lndeathsblag size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid)
regress lnkidnap infight lndeathsblag foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag ln_gdp ln_pop pts_a efindex, cluster(panelid)

* Results with Fixed Effects (Table A7)
regress lnkidnap infight_b c.lndeathsb kidnap_lag terror_lag soft_lag i.year i.panelid, cluster(panelid)
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag i.year i.panelid, cluster(panelid)
regress lnkidnap infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag ln_gdp ln_pop pts_a efindex i.year i.panelid, cluster(panelid)

* Additional Control Variables (Table A8)
regress lnkidnap infight_b lndeathsb ageorg ageorg2 size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid)
regress lnkidnap infight_b lndeathsb ageorg ageorg2 foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag ln_gdp ln_pop pts_a efindex, cluster(panelid)

* Results without the Taliban, Afghanistan (Table A9)
regress lnkidnap infight_b c.lndeathsb kidnap_lag terror_lag soft_lag, cluster(panelid), if side_b != "Taleban"
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid), if side_b != "Taleban"
regress lnkidnap infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag ln_gdp ln_pop pts_a efindex, cluster(panelid), if side_b != "Taleban"

* Results without Yearly Battle Deaths Limitation (Table A10)
use tac_allyears.dta, clear

regress lnkidnap infight_b c.lndeathsb kidnap_lag terror_lag softratio_lag, cluster(panelid)
regress lnkidnap infight_b lndeathsb size nat left rel regimetype territory kidnap_lag terror_lag softratio_lag, cluster(panelid)
regress lnkidnap infight_b lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag softratio_lag ln_gdp, cluster(panelid)

* Ransom and Non-Ransom Kidnappings Placebo (Table A11)
use welsh23_macro.dta, clear

regress lnkidnap infight_b lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid)
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid), if ransomrequest == 1
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid), if ransomrequest == 0

* Victims of Kidnapping Attacks Placebo (Table A12)
regress govtkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid), if territory == 0
regress kidnapcivilian i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid)
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid), if victim_f == 0

* Attribution of Attacks (Table A13)
regress lnkidnap i.infight_b c.lndeathsb kidnap_lag terror_lag soft_lag, cluster(panelid), if claimedplacebo == 0
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid), if claimedplacebo == 0
regress lnkidnap infight_b lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag ln_gdp ln_pop pts_a efindex, cluster(panelid), if claimedplacebo == 0


* Designation Placebo Tests (Table A14)
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag us_desig, cluster(panelid)
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag, cluster(panelid), if us_desig == 0
regress lnkidnap i.infight_b c.lndeathsb foreignspon size nat left rel regimetype territory kidnap_lag terror_lag soft_lag us_desig, cluster(panelid), if us_desig == 1

**************************************************
* MICRO-LEVEL ANALYSIS
**************************************************
use taliban_2_sp.dta, clear 
/// * Linked shapefile: AFG_adm1_shp.dta

* Create W
* spmatrix create contiguity W if iyear == 2018

* Spatial Autoregressive Model (Table A15)
spxtregress ln_kidnap infightv ln_deaths ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)
spxtregress ln_kidnap infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)

* Computed Effects
* Substantive Effect for Battle Losses
spxtregress ln_kidnap infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)
estat impact ln_deaths
margins, at(ln_deaths = (0(0.1)8)) predict(xb)
marginsplot, recast(line) recastci(rarea)

* Directed Effects for Battle Losses
spxtregress ln_kidnap i.infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)
estat impact ln_deaths

use infight_battlefx.dta, clear
twoway (bar dydx fx if effect=="direct") ///
       (bar dydx fx if effect=="indirect") ///
       (bar dydx fx if effect=="total") ///
       (rcap cimin cimax fx)

* Substantive Effect for Violent Competition
use taliban_2_sp.dta, clear 

spxtregress ln_kidnap i.infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)
estat impact infightv
margins infightv, predict(xb)
marginsplot,  recast(scatter)

* Directed Effects for Violent Competition
spxtregress ln_kidnap i.infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)
estat impact infightv

use infight_spatialfx.dta, clear
twoway (bar dydx fx if effect=="direct") ///
       (bar dydx fx if effect=="indirect") ///
       (bar dydx fx if effect=="total") ///
       (rcap cimin cimax fx)
	   
* Robust to Different W Specification
use taliban_2_sp.dta, clear 
/// * Linked shapefile: AFG_adm1_shp.dta

spxtregress ln_kidnap infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W) errorlag(W)
spxtregress ln_kidnap infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W) errorlag(W) ivarlag(W: infightv ln_deaths)

* Binary Dependent Variable (Table A16)
spxtregress kidnap_binary infightv ln_deaths ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)
spxtregress kidnap_binary infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)

* Non-Spatial Linear Model (Table A17)
xtreg ln_kidnap infightv ln_deaths ln_kidnap_lag terr_minus_lag osv_lag, fe
xtreg ln_kidnap infightv ln_deaths_lag ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe

* Non-Spatial Binary Model (Table A18)
xtreg kidnap_binary infightv ln_deaths ln_kidnap_lag terr_minus_lag osv_lag, fe
xtreg kidnap_binary infightv ln_deaths_lag ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe

* Tabliban Terrorist Attacks Placebo (Table A19)
xtreg propsoft infightv ln_deaths territory osv_lag terr_minus_lag i.iyear, fe
xtreg propsoft infightv ln_deaths_lag ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe

* Disequilibtrium Test (Table A20)
* Reported results for linear model (non-spatial)
 xtreg ln_kidnap infightv ln_deaths_lag ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe

* New high losses + territorial control = high kidnap (effect not supproted -- no stat. difference between areas in control and no control)
xtreg ln_kidnap infightv c.ln_deaths##territory ln_pop ln_kidnap_lag terr_minus_lag osv_lag i.iyear, fe 

* Old losses + control = less (not supported either)
xtreg ln_kidnap infightv c.ln_deaths_lag##territory ln_pop ln_kidnap_lag terr_minus_lag osv_lag i.iyear, fe

* Probing Issues of Resource Extraction (Table A22)
spxtregress ln_kidnap infightv ln_deaths ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)
spxtregress ln_kidnap i.infightv ln_deaths taliban_cultivate cultivate ln_opium ln_pop territory ln_kidnap_lag terr_minus_lag osv_lag, fe dvarlag(W)

* Probing Mechanisms for Violent Competition (Table A23)
* Test extraction (Taliban take civilians from Taliban constituencies)
xtreg lnkidnapciv i.infightv ln_kidnap_lag terr_minus_lag osv_lag, fe

margins infightv, post
marginsplot, recast(bar)
* graph save civilians_taliban1.gph

* Test outbidding (Taliban take civilians from ISK constituencies)
xtreg lnkidnapciv i.infightv ln_kidnap_lag terr_minus_lag osv_lag, fe, if isi == 1

margins infightv, post
marginsplot, recast(bar)
* graph save civilians_isk1.gph
* graph combine civilians_taliban1.gph civilians_isk1.gph 

* Probing Issues of Underreporting (Table A21)
use cell_afghan.dta, clear

regress kidnap cell, cluster(pid)

* Vector Autoregression: Battle Losses
use var_afghanistan.dta, clear

varsoc kidnap max_strike, maxlag()
varbasic kidnap max_strike, lags(1/2)

	#delimit ;
	irf graph oirf, impulse(max_strike) response(kidnap) 
					plot1opts(lc(navy) lw(medium))
					ci1opts(color(black%10) lc(white%10))
					byopts(note("") legend(off)) 
					title("", size(vlarge) margin(medsmall) box bexpand fc(gs16) lw(thin) linegap(2))
					subtitle("", size(medlarge) margin(medsmall) box bexpand fc(gs14) lw(thin) linegap(2))
					xtitle("Months")
					ytitle("")
					yline(0, lcolor(gs0) lw(vthin) lp(shortdash))
					scheme(s1mono)
					xlabel(0(1)8)
					yscale(range(-0.1 1.2))
					ylabel(-1(0.5) 3, nogrid)
					ysize(1) xsize(1)
					saving(g2, replace)

	;
	#delimit cr

* Vector Autoregression: Violent Competition
varsoc kidnap infight_t, maxlag()
varbasic kidnap infight_t, lags(1/2)

	#delimit ;
	irf graph oirf, impulse(infight_t) response(kidnap) 
					plot1opts(lc(navy) lw(medium))
					ci1opts(color(black%10) lc(white%10))
					byopts(note("") legend(off)) 
					title("", size(vlarge) margin(medsmall) box bexpand fc(gs16) lw(thin) linegap(2))
					subtitle("", size(medlarge) margin(medsmall) box bexpand fc(gs14) lw(thin) linegap(2))
					xtitle("Months")
					ytitle("")
					yline(0, lcolor(gs0) lw(vthin) lp(shortdash))
					scheme(s1mono)
					xlabel(0(1)8)
					yscale(range(-0.1 1.2))
					ylabel(-1(0.5) 3, nogrid)
					ysize(1) xsize(1)
					saving(g2, replace)

	;
	#delimit cr

* Vector Autoregression: Alternative Lags for Battle Losses
varsoc kidnap max_strike, maxlag()

varbasic kidnap max_strike, lags(1/3)

	#delimit ;
	irf graph oirf, impulse(max_strike) response(kidnap) 
					plot1opts(lc(navy) lw(medium))
					ci1opts(color(black%10) lc(white%10))
					byopts(note("") legend(off)) 
					title("", size(vlarge) margin(medsmall) box bexpand fc(gs16) lw(thin) linegap(2))
					subtitle("", size(medlarge) margin(medsmall) box bexpand fc(gs14) lw(thin) linegap(2))
					xtitle("Months")
					ytitle("")
					yline(0, lcolor(gs0) lw(vthin) lp(shortdash))
					scheme(s1mono)
					xlabel(0(1)8)
					yscale(range(-0.1 1.2))
					ylabel(-1(0.5) 3, nogrid)
					ysize(1) xsize(1)
					saving(g2, replace)

	;
	#delimit cr

* Vector Autoregression: Alternative Lags for Violent Competition
varsoc kidnap infight_t, maxlag()

varbasic kidnap infight_t, lags(1/4)

	#delimit ;
	irf graph oirf, impulse(infight_t) response(kidnap) 
					plot1opts(lc(navy) lw(medium))
					ci1opts(color(black%10) lc(white%10))
					byopts(note("") legend(off)) 
					title("", size(vlarge) margin(medsmall) box bexpand fc(gs16) lw(thin) linegap(2))
					subtitle("", size(medlarge) margin(medsmall) box bexpand fc(gs14) lw(thin) linegap(2))
					xtitle("Months")
					ytitle("")
					yline(0, lcolor(gs0) lw(vthin) lp(shortdash))
					scheme(s1mono)
					xlabel(0(1)8)
					yscale(range(-0.1 1.2))
					ylabel(-1(0.5) 3, nogrid)
					ysize(1) xsize(1)
					saving(g2, replace)

	;
	#delimit cr
